<template>
  <div class="aui-card-list">
  <uni-list-query-card :queryShow="queryShow" @query-click="getDataList()" @click="(e)=>{this.queryShow=e}" @searchReset="searchReset()">
      <el-col :span="6">
        <el-form-item label="应用ID">
          <el-input v-model="dataForm.appId" placeholder="应用ID" clearable></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="接口方法">
          <el-input v-model="dataForm.method" placeholder="接口方法" clearable></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label="接口请求签名">
          <el-input v-model="dataForm.sign" placeholder="接口请求签名" clearable></el-input>
        </el-form-item>
      </el-col>
  </uni-list-query-card>
    <el-card shadow="never" class="aui-card--fill">
      <vxe-toolbar :setting="{immediate:true}">
        <template v-slot:buttons>
        </template>
        <template v-slot:tools>
          <el-button icon="el-icon-search" @click="searchShowHandle()" circle></el-button>
          <el-button icon="el-icon-refresh" @click="getDataList()" circle></el-button>
          <!-- <el-button icon="el-icon-download" @click="$refs.xTable.openExport()" circle></el-button> -->
        </template>
      </vxe-toolbar>
      <vxe-table ref="xTable" :loading="dataListLoading" class="vxe-table-element" auto-resize :data="dataList"
        column-width="auto">
        <vxe-table-column type="index" align="center" fixed="left" width="60"></vxe-table-column>
        <vxe-table-column field="appId" title="应用ID" fixed="left" width="100">
        </vxe-table-column>
        <vxe-table-column field="method" title="接口method" fixed="left" width="120">
        </vxe-table-column>
        <vxe-table-column field="timestamp" title="请求时间" fixed="left" width="140">
        </vxe-table-column>
        <vxe-table-column field="sign" title="请求签名" fixed="left" width="200">
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">{{scope.row.sign}}</el-button>
          </template>
        </vxe-table-column>
        <vxe-table-column field="requestParams" title="请求参数" width="200">
        </vxe-table-column>
        <vxe-table-column field="requestBody" title="请求body参数" width="200">
        </vxe-table-column>
        <vxe-table-column field="receiptStatus" title="接收状态" width="100">
          <template slot-scope="scope">
            <el-tag v-if="!scope.row.receiptStatus" size="small" type="danger">失败</el-tag>
            <el-tag v-else size="small" type="success">成功</el-tag>
          </template>
        </vxe-table-column>
        <vxe-table-column field="responseStr" title="响应数据" width="140">
        </vxe-table-column>
        <vxe-table-column field="createDate" title="创建时间" width="140">
        </vxe-table-column>
      </vxe-table>
      <el-pagination :current-page="page" :page-sizes="[10, 20, 50, 100]" :page-size="limit" :total="total"
        layout="total, sizes, prev, pager, next, jumper" @size-change="pageSizeChangeHandle"
        @current-change="pageCurrentChangeHandle">
      </el-pagination>
      <!-- 弹窗, 新增 / 修改 -->
      <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
    </el-card>
  </div>
</template>
<script>
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './apiLog-add-or-update'
export default {
  mixins: [mixinViewModule],
  data () {
    return {
      searchShow: true,
      mixinViewModuleOptions: {
        getDataListURL: '/api/apiReceiptLog/page',
        getDataListIsPage: true,
        deleteURL: '/api/apiReceiptLog',
        deleteIsBatch: true,
        exportURL: '/api/apiReceiptLog/export'
      },
      dataForm: {
        appId: '',
        method: '',
        sign: ''
      }
    }
  },
  components: {
    AddOrUpdate
  }
}
</script>
